Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Fixed regression for extensions. Updated docs to remove the rootURL … #1463

Merged
merged 1 commit into from
Sep 20, 2017
Merged

Fixed regression for extensions. Updated docs to remove the rootURL … #1463

merged 1 commit into from
Sep 20, 2017

Conversation

RobBagby
Copy link
Contributor

This pull request address an issue with extensions. The issue has to do with the following code that does the token replacement for EXTENSION_LOOP_COUNT.

Original Replace Code

dta = strings.Replace(dta, "EXTENSION_LOOP_COUNT", loopCount, -1)

Template that has the token that is being replaced - template-link.json

{
    "name": "[concat(EXTENSION_TARGET_VM_NAME_PREFIX, copyIndex(EXTENSION_LOOP_OFFSET), 'HelloWorldDcos')]",
    "type": "Microsoft.Resources/deployments",
    "apiVersion": "[variables('apiVersionLinkDefault')]",
    "dependsOn": [
        "[resourceId('Microsoft.Compute/virtualMachines/extensions', concat(variables('masterVMNamePrefix'), sub(variables('masterCount'), 1)), 'waitforleader')]"
    ],
    "copy": {
        "count": "EXTENSION_LOOP_COUNT",
        "name": "helloWorldExtensionLoop"
    },

In the event that the code that is replacing the token is an expression, everything is fine. In the event that the code that the replacing code is an integer, this causes and error. An integer cannot be surrounded by quotes. This causes extensions such as hello-world-dcos to fail on deployment. See failing code below:

    {
      "apiVersion": "[variables('apiVersionLinkDefault')]",
      "copy": {
        "count": "1",
        "name": "helloWorldExtensionLoop"
      },
      "dependsOn": [
        "[resourceId('Microsoft.Compute/virtualMachines/extensions', concat(variables('masterVMNamePrefix'), sub(variables('masterCount'), 1)), 'waitforleader')]"
      ],

Updated Code
The changed code simply checks the replacing code to see if it is an integer or not. If it is an integer it replaces the token, along with the surrounding quotes. If not, it simply replaces the token. See below.

if _, err := strconv.Atoi(loopCount); err == nil {
    dta = strings.Replace(dta, "\"EXTENSION_LOOP_COUNT\"", loopCount, -1)
} else {
    dta = strings.Replace(dta, "EXTENSION_LOOP_COUNT", loopCount, -1)
}

2 other files were changed - both documentation - removing the reference to rootURL - which is a development concern.

@msftclas
Copy link

@RobBagby,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@jackfrancis
Copy link
Member

Thanks @RobBagby !

@jackfrancis jackfrancis merged commit 83e4fdb into Azure:master Sep 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants